﻿using PetaPoco;
using System;
using System.ComponentModel.DataAnnotations;

namespace Cxuu.Models
{

    [TableName("cxuu_article")]
    [PrimaryKey("Id", AutoIncrement = true)]
    public class Article
    {
        /// <summary>
        /// ID
        /// </summary>
        public int Id { get; set; }
        /// <summary>
        /// 类别
        /// </summary>
        public int Cid { get; set; }
        /// <summary>
        /// 标题
        /// </summary>
        public string Title { get; set; }
        /// <summary>
        /// 附件
        /// </summary>
        public string Attments { get; set; }
        /// <summary>
        /// 用户ID
        /// </summary>
        public int Uid { get; set; }
        /// <summary>
        /// 状态标识
        /// </summary>
        public int Miji { get; set; } = 0;
        /// <summary>
        /// 信息报送时间
        /// </summary>
        public DateTime GreatTime { get; set; }
        /// <summary>
        /// 写入系统时间
        /// </summary>
        public DateTime InsertTime { get; set; } = DateTime.Now;
        /// <summary>
        /// 文号
        /// </summary>
        public int DocNumber { get; set; }

        /// <summary>
        /// 报送部门
        /// </summary>
        public string Department { get; set; }
        /// <summary>
        /// 报送领导
        /// </summary>
        public string Leader { get; set; }
        /// <summary>
        /// 审签
        /// </summary>
        public string Examine { get; set; }
        /// <summary>
        /// 拟稿
        /// </summary>
        public string Auther { get; set; }
        /// <summary>
        /// 校对
        /// </summary>
        public string Proofread { get; set; }
        /// <summary>
        /// 初审
        /// </summary>
        public string EarlierExa { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remarks { get; set; }
    }


    public class EditArticleAndContent
    {
        public int Id { get; set; }
        [Display(Name = "类别")]
        [Required(ErrorMessage = "请选择类别")]
        public int Cid { get; set; }
        [Display(Name = "拟文标题")]
        [Required(ErrorMessage = "拟文标题未填写")]
        public string Title { get; set; }
        public string Attments { get; set; }

        [Display(Name = "报送时间")]
        [Required(ErrorMessage = "时间未填写")]
        public DateTime GreatTime { get; set; }
        public DateTime InsertTime { get; set; } = DateTime.Now;
        [Display(Name = "密级")]
        public int Miji { get; set; }
        [Display(Name = "内容")]
        public string Content { get; set; }
        [Display(Name = "文号")]
        public int DocNumber { get; set; }
        [Display(Name = "报送部门")]
        public string Department { get; set; }
        [Display(Name = "报送领导")]
        public string Leader { get; set; }
        [Display(Name = "拟稿")]
        public string Auther { get; set; }
        [Display(Name = "校对")]
        public string Proofread { get; set; }
        [Display(Name = "初审")]
        public string EarlierExa { get; set; }
        [Display(Name = "审签")]
        public string Examine { get; set; }

        [Display(Name = "备注")]
        public string Remarks { get; set; }
        public string CateName { get; set; }
        public string DeptName { get; set; }
        public int Uid { get; set; }
        public Article AsArticle()
        {
            return new Article
            {
                Id = Id,
                Cid = Cid,
                Uid = Uid,
                Title = Title,
                Attments = Attments,
                Miji = Miji,
                GreatTime = GreatTime,
                InsertTime = InsertTime,
                DocNumber = DocNumber,
                Department = Department,
                Leader = Leader,
                Examine = Examine,
                Auther = Auther,
                Proofread = Proofread,
                EarlierExa = EarlierExa,
                Remarks = Remarks,
            };
        }

        public ArticleContent AsArticleContent()
        {
            return new ArticleContent
            {
                Aid = Id,
                Content = Content
            };
        }
    }



    public class ViewArticleAndCate
    {
        public int Id { get; set; }
        public int Cid { get; set; }
        public int Uid { get; set; }
        public string Title { get; set; }
        public string CateName { get; set; }
        public string DeptName { get; set; }
        public string Nickname { get; set; }
        /// <summary>
        /// 对象标识1
        /// </summary>
        public int Miji { get; set; }
        /// <summary>
        /// 信息报送时间
        /// </summary>
        public DateTime GreatTime { get; set; }
        /// <summary>
        /// 写入系统时间
        /// </summary>
        public DateTime InsertTime { get; set; }
        /// <summary>
        /// 文号
        /// </summary>
        public int DocNumber { get; set; }
        /// <summary>
        /// 报送部门
        /// </summary>
        public string Department { get; set; }
        /// <summary>
        /// 报送领导
        /// </summary>
        public string Leader { get; set; }
        /// <summary>
        /// 审签
        /// </summary>
        public string Examine { get; set; }
        /// <summary>
        /// 拟稿
        /// </summary>
        public string Auther { get; set; }
        /// <summary>
        /// 校对
        /// </summary>
        public string Proofread { get; set; }
        /// <summary>
        /// 初审
        /// </summary>
        public string EarlierExa { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remarks { get; set; }

        /// <summary>
        /// 标记状态
        /// </summary>
        public string Mark { get; set; }


    }

    /// <summary>
    /// 查询模型
    /// </summary>
    public class ArticleQuery : Page<ViewArticleAndCate>
    {
        public string Cid { get; set; }
        public string SearchCid { get; set; }
        public int Limit { get; set; } = 15;
        public int Page { get; set; } = 1;
        public string Orderby { get; set; }
        public int Uid { get; set; }
        public string Uids { get; set; }
        public string Title { get; set; }
        public string NickName { get; set; }
        public DateTime? StartDate { get; set; }
        public DateTime? EndDate { get; set; }
        public int FullTextSwitch { get; set; }
        public int MarkStatus { get; set; }
    }

    /// <summary>
    /// 查询模型
    /// </summary>
    public class ArticleCount
    {
        public int Cids { get; set; }
        public string Name { get; set; }
        public int Value { get; set; }
        public int MarkNum { get; set; }
    }

    /// <summary>
    /// 统计模型
    /// </summary>
    public class NumCount
    {
        public long Article { get; set; }
        public long User { get; set; }
        public long Docreceived { get; set; }
        public long Statement { get; set; }
        public long Log { get; set; }
        public long Notice { get; set; }
    }
}


